<template>
	<view class="contain">
		<div class="zixun_list">
			<div class="item_wrap row_between" @tap="goToH5(zixunList[index].newsUrl)" v-for="(item, index) in zixunList" :key="index" @longpress="toDel(item, index)">
				<div class="col_between content_wrap">
					<span class="title">{{ item.title }}</span>
					<div class="row_between" style="width: 100%; margin-top: 0upx; font-size: 24upx;">
						<span>{{ item.publishDateStr }}</span>
						<span>{{ item.viewCount }}阅读</span>
					</div>
				</div>
				<image :src="item.picUrl" mode="aspectFill" class="image"></image>
				<image src="../../../static/img/default_icon.png" mode="aspectFill" class="default_image"></image>
			</div>
		</div>
		<!-- 底部弹窗 -->
		<uni-popup ref="popup" :type="type" @change="change">
			<view class="delete" @tap="del">删除</view>
			<view class="middle"></view>
			<view class="cancel" @tap="cancel">取消</view>
		</uni-popup>
	</view>
</template>

<script>
import uniPopup from '@/components/uni-popup/uni-popup.vue';
export default {
	components: {
		uniPopup
	},
	data() {
		return {
			type: 'bottom',
			open: 'popup',
			tempDelData: '',
			zixunList: [
				{
					newsUrl: 'http://www.91fld.com/news/financial/611.html',
					picUrl: 'http://static.91fld.com/dev/image/newsimages/o_1dlhahtcgvasiimok61i5s7s38.jpg',
					publishDateStr: '2天前',
					publishLong: 1569318306000,
					title: '最新！珠海警方通报“新玉猫国际”平台涉非法集资遭立案',
					viewCount: 2
				},
				{
					newsUrl: 'http://www.91fld.com/news/financial/610.html',
					picUrl: 'http://static.91fld.com/dev/image/newsimages/o_1dlhae34q1uvkg7ikp61qqcee18.jpg',
					publishDateStr: '2天前',
					publishLong: 1569318180000,
					title: '百行征信回应：与各股东方保持良好合作关系',
					viewCount: 3
				},
				{
					newsUrl: 'http://www.91fld.com/news/fund/609.html',
					picUrl: 'http://static.91fld.com/dev/image/newsimages/o_1dlha9tah10h11n70ihg18nai8j8.jpg',
					publishDateStr: '2天前',
					publishLong: 1569318043000,
					title: '公募规模逼近14万亿 这两类基金又火了',
					viewCount: 1
				},
				{
					newsUrl: 'http://www.91fld.com/news/fund/608.html',
					picUrl: 'http://static.91fld.com/dev/image/newsimages/o_1dlgs5904hae13lo1hrgr13sg58.jpg',
					publishDateStr: '3天前',
					publishLong: 1569303211000,
					title: '超30%百亿私募以逾八成仓位运作 估值修复行情将继续',
					viewCount: 1
				},
				{
					newsUrl: 'http://www.91fld.com/news/financial/607.html',
					picUrl: 'http://static.91fld.com/dev/image/newsimages/o_1dlgrudk21h78147ajq1nl51d958.jpg',
					publishDateStr: '3天前',
					publishLong: 1569302987000,
					title: '基金齐声唱多:黄金上涨仍在路上',
					viewCount: 3
				},
				{
					newsUrl: 'http://www.91fld.com/news/macro/606.html',
					picUrl: 'http://static.91fld.com/dev/image/newsimages/o_1dlgmdp8i2kn1pokmt9mv170u8.jpg',
					publishDateStr: '3天前',
					publishLong: 1569297198000,
					title: '中国要不要降息？刚刚，易纲回应了',
					viewCount: 5
				},
				{
					newsUrl: 'http://www.91fld.com/news/macro/605.html',
					picUrl: 'http://static.91fld.com/dev/image/newsimages/o_1dlgj6qq760d1ep6930at6leu8.jpg',
					publishDateStr: '3天前',
					publishLong: 1569293825000,
					title: '欧元区缺乏明显经济复苏迹象 欧洲央行随时准备再降息',
					viewCount: 0
				},
				{
					newsUrl: 'http://www.91fld.com/news/financial/604.html',
					picUrl: 'http://static.91fld.com/dev/image/newsimages/o_1dlgj1rfd1k0katgn85spi9t28.jpg',
					publishDateStr: '3天前',
					publishLong: 1569293662000,
					title: '限额缩水 禁止透支：信用卡涉房交易监管步步升级',
					viewCount: 5
				},
				{
					newsUrl: 'http://www.91fld.com/news/fund/603.html',
					picUrl: 'http://static.91fld.com/dev/image/newsimages/o_1dlgh6hdm1h2j1u5opu61q0h43c8.jpg',
					publishDateStr: '3天前',
					publishLong: 1569291718000,
					title: '“金主”频频发力 ETF再迎巨无霸',
					viewCount: 1
				},
				{
					newsUrl: 'http://www.91fld.com/news/fund/602.html',
					picUrl: 'http://static.91fld.com/dev/image/newsimages/o_1dlgh034jelm136p1o0h1mlhgmd8.jpg',
					publishDateStr: '3天前',
					publishLong: 1569291520000,
					title: '央企创新驱动ETF受追捧 4基金合计募资超400亿',
					viewCount: 0
				}
			]
		};
	},
	methods: {
		goToH5: function(url) {
			if (this.getUrlQueryString(url, 'needlogin') == 1) {
				// 需要登录
				let auth_token = uni.getStorageSync('auth_token');
				if (auth_token) {
					// 可以登录
					if (this.getUrlQueryString(url, 'hidehead') == 1) {
						// 需要隐藏头
						uni.setStorageSync('couponUrl', url);
						console.log(url);
						uni.navigateTo({
							url: '/pages/tixian_webview/tixian_webview?url=' + url
						});
					} else {
						uni.navigateTo({
							url: '/pages/home_webview/home_webview?url=' + url
						});
					}
				} else {
					uni.navigateTo({
						url: '/pages/get_code/get_code'
					});
				}
			} else {
				// 不需要登录
				if (this.getUrlQueryString(url, 'hidehead') == 1) {
					// 需要隐藏头
					uni.setStorageSync('couponUrl', url);
					console.log(url);
					uni.navigateTo({
						url: '/pages/tixian_webview/tixian_webview?url=' + url
					});
				} else {
					uni.navigateTo({
						url: '/pages/home_webview/home_webview?url=' + url
					});
				}
			}
		},
		getUrlQueryString(url, name) {
			var reg = new RegExp('[?&]' + name + '=([^&#]*)', 'i');
			var res = url.match(reg);

			if (res && res.length > 1) {
				return decodeURIComponent(res[1]);
			}
			return '';
		},
		toDel(item, index) {
			this.tempDelData = index;
			this.$refs[this.open].open();
		},
		cancel() {
			this.$refs[this.open].close();
		},
		del() {
			this.zixunList.splice(this.tempDelData, 1);
			this.cancel();
		},
		change(e) {
			console.log(e.show);
		}
	},
	onUnload() {
		this.tempDelData = '';
	}
};
</script>

<style lang="scss">
.zixun_list {
	margin-bottom: 0upx;
	background: #ffffff;
	padding: 0upx 30upx;
}
.zixun_list .item_wrap {
	height: 180upx;
	width: 100%;
	box-sizing: border-box;
}
.zixun_list .item_wrap .content_wrap {
	height: 140upx;
	flex: 1;
	color: #999999;
	font-size: 16upx;
	line-height: 1;
}
.zixun_list .item_wrap .content_wrap .title {
	color: #303030;
	font-size: 32upx;
	font-weight: bold;
	line-height: 1.3;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}
.zixun_list .item_wrap .image {
	height: 130upx;
	width: 180upx;
	position: relative;
	z-index: 2;
	margin-left: 27upx;
	min-height: 130upx;
	min-width: 180upx;
}
.zixun_list .item_wrap .default_image {
	height: 130upx;
	width: 180upx;
	position: absolute;
	right: 0upx;
	margin-left: 27upx;
	min-height: 130upx;
	min-width: 180upx;
	position: absolute;
	right: 30upx;
}
.btn {
	height: 94upx;
	line-height: 94upx;
	width: 236upx;
	background: #ffca0a;
	border-radius: 12upx;
	text-align: center;
	color: #303030;
	font-size: 36upx;
	margin-top: 70upx;
	font-weight: bold;
}
.delete {
	text-align: center;
	height: 100upx;
	line-height: 100upx;
	color: #fe4444;
	font-size: 32upx;
	font-weight: bold;
}
.middle {
	width: 100%;
	height: 20upx;
	background: #f5f5f5;
}
.cancel {
	text-align: center;
	height: 100upx;
	line-height: 100upx;
	font-size: 32upx;
	font-weight: 500;
}
</style>
